package cqncer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author ash022
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.biojava.bio.gui.sequence.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.symbol.*;
 
public class MultiView extends JFrame {
  private JPanel jPanel = new JPanel();
  private MultiLineRenderer mlr = new MultiLineRenderer();
  private SequenceRenderer symR = new SymbolSequenceRenderer();
  private RulerRenderer ruler = new RulerRenderer();
  private SequencePanel seqPanel = new SequencePanel();
  private Sequence seq;
 
 
  public MultiView() {
    try {
      seq = ProteinTools.createProteinSequence(
          "agcgstyravlivtymaragrsecharlvahklchg",
          "protein 1");
      init();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
 
  /**
   * OverRide to allow termination of program.
   */
  protected void processWindowEvent(WindowEvent we){
    if (we.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
    else {
      super.processWindowEvent(we);
    }
  }
 
  /**
   * Set up GUI components
   */
  private void init() throws Exception {
    this.setTitle("MultiView");
    this.getContentPane().add(jPanel, BorderLayout.CENTER);
    jPanel.add(seqPanel, BorderLayout.CENTER);
 
    //add the SymbolSequenceRenderer and RulerRenderer to the MultiLineRenderer
    mlr.addRenderer(symR);
    mlr.addRenderer(ruler);
 
    //set the MultiLineRenderer as the main renderer
    seqPanel.setRenderer(mlr);
 
    //set the Sequence
    seqPanel.setSequence(seq);
 
    //set the range to show
    seqPanel.setRange(new RangeLocation(1,seq.length()));
  }
}